<script >
	function addElement() {

	  var ni = document.getElementById('myDiv');

	  var numi = document.getElementById('theValue');

	  var num = (document.getElementById('theValue').value -1)+ 2;

	  numi.value = num;

	  var newdiv = document.createElement('div');

	  var divIdName = 'my'+num+'Div';

	  newdiv.setAttribute('id',divIdName);
	  newdiv.setAttribute('style','float:left; width:100%');

	  newdiv.innerHTML = '<p><input type="hidden" id="userfile'+num+'" name="sanpham_hinhanh'+num+'" value=""/><img src="" width="50" id="imgdef'+num+'" name="imgdef'+num+'" height="40" style="float:left; border:#CCC 1px solid" /><input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open(\'Upfile.php?Dir=sanpham&amp;form=userfile'+num+'&img=imgdef'+num+'\',\'_upLoad\' ,\'height=220,width=450,resizable=no,scrollbars=yes\')") />&nbsp; <a href="javascript:;" onclick="removeElement(\''+divIdName+'\');">Xóa</a></p>';

	  ni.appendChild(newdiv);

	}
	function removeElement(divNum) {

	  var vl = document.getElementById('theValue');
	  vl.value= vl.value-1;
	  var d = document.getElementById('myDiv');

	  var olddiv = document.getElementById(divNum);

	  d.removeChild(olddiv);

	}
</script>
<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

	// O2k7 skin
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		width : "700",
		height : "150",
		skin : "o2k7",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,autosave,visualblocks",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,sub,sup,link,unlink,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_path : false, 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		

	});
				
/* Default skin */



</script>

<form style="padding:0; margin:0" action="index.php?tn=marketing&ma=care_submit" method="post" name="frmAddMessage" enctype="multipart/form-data">

   <?php 
	$id=$_GET['id'];
	$sql_kh=mysql_query("select * from tb_marketing where IDmarketing='$id'");
	$rs_kh=mysql_fetch_array($sql_kh)
?>  
        <div class="clear" style="height:5px"></div>
       <input type="hidden" name="kh_id" value="<?php echo $rs_kh['IDmarketing'];?>"/>
        <div class="clear" style="height:5px"></div>
        <div class="bodycontent">
        <table class="box-vang" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td class="t-l" width="8px"></td>
            <td class="t-c"></td>
            <td class="t-r" width="8px"></td>
          </tr>
          <tr class="light">
            <td class="c-l"></td>
            <td class="c-c"><table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody><tr class="light">
                  <td class="title-red" colspan="2" align="left">&nbsp;Xem chi tiết chiến dịch Marketing<span style="float:right"><?php echo date('d/m/Y H:i:s a',$rs_kh['marketing_ngaytao']);?> </span></td>
                </tr>
               
                <tr>
                  <td class="title-red1" colspan="2">Thông tin chung</td></tr>
                <tr class="light">
                  <td width="319" style="padding:10px">
         			<table>
                    
                    <tr>
                      <td align="right"><strong>Tên chiến dịch:</strong>: </td>
                      <td><?php echo $rs_kh['Tenchiendich'];?></td></tr>
                      
                  <tr>
                       <td align="right"><strong>Mã chiến dịch:</strong></td>
                       <td><?php echo $rs_kh['Maso'];?></td></tr>
                       
                   <?php 
					$sql_lkh=mysql_query("
					select services_type_name,services_type_id  from tb_services_type where phanloai_id=20 and services_type_id='".$rs_kh['IDloai']."'					
					");
					$rs_lkh=mysql_fetch_array($sql_lkh);
										
				?>
                   <tr>
                       <td align="right"><strong>Loại chiến dịch:</strong></td>
                       <td><?php echo $rs_lkh['services_type_name'];?></td></tr>
                       
                  <tr>
                       <td align="right"><strong>Trạng thái:</strong></td>
                       <td> 	
<?php 
				$trangthai = $rs_kh['marketing_trangthai'];
				if($trangthai==1){
				?> Đang lên kế hoạch
                <?php }?>
                <?php 
				$trangthai = $rs_kh['marketing_trangthai'];
				if($trangthai==2){
				?><font color="#CC3300"><b>Sẵn sàng thực hiện</b></font>
                <?php }?>
                <?php 
				$trangthai = $rs_kh['marketing_trangthai'];
				if($trangthai==3){
				?><font color="#009900"><b>Đang thực hiện</b></font>
                <?php }?>
                 <?php 
				$trangthai = $rs_kh['marketing_trangthai'];
				if($trangthai==4){
				?><font color="#000000"><b>Chiến dịch hoàn thành</b></font>
                <?php }?>
                 <?php 
				$trangthai = $rs_kh['marketing_trangthai'];
				if($trangthai==5){
				?><font color="#CCCCCC"><b>Chiến dịch hủy</b></font>
                <?php }?> </td></tr> 
                   
                    </table> 
                  </td> 
                 <td width="273" style="padding:10px">
         			<table>
                    <tr>
                      <td align="right"><strong>Liên quan tới sản phẩm:</strong></td>
                      <td> <?php 
					  	$product_id=explode(',',$rs_kh['IDSanpham']);
						$so_product=count($product_id)-1;
						for($p=1;$p<=$so_product;$p++)
						{
							$tong_product=$product_id[$p-1];
						
							$sql_pr=mysql_query("select IDproduct,Namepro from tb_product where IDproduct='$tong_product'");
							while($rs_pr=mysql_fetch_array($sql_pr))
							{
								echo $rs_pr['Namepro'].',';
							}
						}
					  ?></td></tr>
                     <tr>
                       <td align="right"><strong>Ngày bắt đầu:</strong>: </td>
                       <td><?php echo $rs_kh['marketing_batdau'];?></td></tr>  
                      <tr>
                       <td align="right"><strong>Ngày kết thúc:</strong>: </td>
                       <td><?php echo $rs_kh['marketing_ketthuc'];?></td></tr>                     
                    </table> 
                  </td> 
                </tr> 
                
                 <tr>
                   <td class="title-red1" colspan="2">Kỳ vọng kết quả</td></tr>
                <tr class="light">
                  <td style="padding:10px">
         			<table>                    
                     <tr>
                       <td align="right"><strong>Ngân sách cho phép</strong>: </td>
                     <td><?php echo $rs_kh['marketing_ngansach'];?> vnđ</td></tr>
                      <tr>
                        <td align="right"><strong>Số lượng KH mục tiêu</strong>: </td>
                      <td><?php echo $rs_kh['marketing_KHmuctieu'];?></td></tr>
                       <tr>
                         <td align="right"><strong>Số lượng KH kỳ vọng:</strong></td>
                       <td><?php echo $rs_kh['marketing_KHKyvong'];?></td></tr>
                        <tr>
                          <td align="right"><strong>Doanh thu kỳ vọng:</strong></td>
                        <td><?php echo $rs_kh['marketing_DTKyvong'];?></td></tr>                         
                    </table> 
                  </td> 
                 <td style="padding:10px">
         			<table width="503">
                   
                    <tr>
                    <td width="192" align="right"><strong>Chi phí thực tế: </strong></td>
                    <td width="299">0</td></tr>
                    <tr>
                    <td align="right"><strong>Số lượng KH tiếp cận:</strong></td>
                    <td>0</td></tr>
                    <tr>
                    <td align="right"><strong>Số cơ hội bán hàng:</strong></td>
                    <td>0</td></tr>
                    <tr>
                    <td align="right"><strong>Số lượng KH thành công</strong>: </td>
                    <td>0</td></tr>
                   <tr>
                    <td align="right"><strong>Doanh thu thực tế</strong>: </td>
                    <td>0</td></tr>
                    </table> 
                  </td> 
                </tr> 
                
                
                
                
                 <tr><td class="title-red1" colspan="2">Thông tin quản lý</td></tr>
                <tr class="light">
                  <td style="padding:10px">
         			<table>
                     <?php $dvql=mysql_query("select room_id,room_name from tb_room where room_id='".$rs_kh['IDmanager']."'");
						$rs_dvql=mysql_fetch_array($dvql)
					?>
                    <tr>
                      <td align="right"><strong>Đơn vị quản lý</strong>: </td>
                    <td><?php echo $rs_dvql['room_name'];?></td></tr>
                    <tr>
                    <?php $nql=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$rs_kh['account_id']."'");
						$rs_nql=mysql_fetch_array($nql)
					?>
                      <td align="right"><strong>Người quản lý:</strong></td>
                    <td><?php echo $rs_nql['account_name'];?></td></tr>
                    <tr>
                      <td align="right"><strong>Người quản lý khác:</strong></td>
                    <td>&nbsp;Không có ai</td></tr>                    
                    </table> 
                  </td> 
                 <td style="padding:10px">
         			<table>
                   
                    <tr>
                      <td width="129" align="right"><strong>Người tạo:</strong></td>
                       <?php $nql=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$rs_kh['marketing_userupdate']."'");
						$rs_nql=mysql_fetch_array($nql)
					?>
                    <td width="352">Administrator</td></tr>
                    <tr>
                      <td align="right"><strong>Ngày tạo:</strong></td>
                    <td><?php echo date('d/m/Y H:i a',$rs_kh['marketing_ngaytao']);?></td></tr>
                    <tr>
                      <td align="right"><strong>Người cập nhật</strong>: </td>
                    <td><?php echo $rs_kh['marketing_userupdate'];?></td></tr>
                    <tr>
                      <td align="right"><strong>Ngày cập nhật: </strong></td>
                    <td><?php echo date('d/m/Y H:i a',$rs_kh['marketing_Ngayupdate']);?></td></tr>
                   
                    </table> 
                  </td> 
                </tr> 
                   <tr><td class="title-red1" colspan="2">Mô tả chi tiết hơn</td></tr>
                    <tr>
                      <td align="left" colspan="4"><?php echo $rs_kh['marketing_Mota'];?></td>
                   </tr>
                <tr><td height="10px"></td></tr>
                <tr><td colspan="2"></td></tr>
                
              </tbody> </table></td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
         
         
         
         
         
         
         
         
            <div class="break-sub" style="height:10px"></div>
        	 <table class="box-hong" cellpadding="0" cellspacing="0">
					  <tbody><tr class="light">
						<td class="text-l"></td>
						<td class="text-c">
							Lịch sử giao dịch&nbsp; &nbsp;     						 						</td>
						<td class="text-r"></td>
					  </tr>
					</tbody></table>
					<table class="box-hong" cellpadding="0" cellspacing="0" width="100%">
					  <tbody><tr>
						<td class="t-l"></td>
						<td class="t-c"></td>
						<td class="t-r"></td>
					  </tr>
                     
					  <tr class="light">
						<td class="c-l"></td>
						<td class="c-c" valign="top">
                     
                        	<div>
                        <table width="100%" cellspacing="0" cellpadding="0" style="  border-Top:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;  border-bottom:1px solid #2C8834;  border-Left:1px solid #D2D2D2;">
                        <tr height="22px" bgcolor="#A1E3A1" align="center" class="SanPham01">
                        <td width="10%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
                        Người giao dịch</strong></td>
                        <td width="12%"  bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; height:30px;"><strong>
                        Ngày giao dịch</strong></td>
                        <td width="70%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
                        Nội dung</strong></td>
                        <td width="10%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
                        File đính kèm</strong></td>
                        </tr>
                        <?php 
						$sql_care=mysql_query("select * from care_marketing where kh_care='$id' order by id DESC");
						while($rs_care=mysql_fetch_array($sql_care))
						{
						?>
                        <tr onmouseover="this.className='SanPham02hover'" onmouseout="this.className='SanPham02'" class="SanPham02">
                        <td style="border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px"><?php echo $rs_care['user_care'];?></td>
                        <td height="25" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px"><?php echo date('d/m/Y - H:i a',$rs_care['time_care']);?></td>
                        <td style="border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px">
                        <?php echo $rs_care['content_care'];?>
                        </td>
                        <td style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px" align="center">
                        <?php if($rs_care['file_care']!="") {?>
                        <a href="<?php echo $rs_care['file_care'];?>" target="_blank">Tải file</a>
                        <? }?>
                        </td>
                        </tr>
                        <?php }?>  
                        </table>                               
                        </td>
						<td class="c-r"></td>
					  </tr>
					  <tr>
						<td class="b-l"></td>
						<td class="b-c"></td>
						<td class="b-r"></td>
					  </tr>
					</tbody></table>
                  
        
        <div class="break-sub" style="height:10px"></div>
        <table class="box-vang" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr class="light">
            <td class="t-l"></td>
            <td class="t-c"></td>
            <td class="t-r"></td>
          </tr>
          <tr>
            <td class="c-l"></td>
            <td class="c-c" valign="top">
            	
            <table class="font_11" border="0" cellpadding="5" cellspacing="0" width="100%">
                <tbody>
               
                <tr class="light">
                  <td>
                  <strong>Giao dịch thêm
                  </strong>
                  <p></p></td>
                </tr>
                 
               <tr valign="top">
                  <td>
                  <div style="position:relative">
                  	
                    <p style="width:845px;" align="center">
                  		<textarea name="noidung" id="txtnoidung" rows="15" cols="80" style="width: 80%"></textarea> 
                     </p>
					<script>$edit = new PAEditor('$edit','message','paeditor')</script>
                 
                  </div>
                 
                  </td>
               </tr>
                <td id="myDiv">
                    File đính kèm: (*.gif, *.jpg, *.png, .doc, .pdf &lt; &nbsp;5000Kb)
                      <?php $soanh=1;?>
							<div style="float:left; width:100%; margin-top:5px;">
                            
								<input type="hidden" id="userfile1" name="sanpham_hinhanh1"  value=""/>
                             
								<?php $soanhthem=1; if($arr_hinhanh[0]==""){$sanpham_hinhanh="../skins/images/photo.jpg";}else $sanpham_hinhanh = $arr_hinhanh[0];?>
                                 
								<img src="" width="50" id="imgdef1" name="imgdef1" height="40" style="float:left; border:#CCC 1px solid" />
								
								<input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('core/Upfile.php?Dir=content&amp;form=userfile1&img=imgdef1','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								
								<input type="hidden" value="<?php echo $soanhthem?>" name="hdnsoanh" id="theValue" />
								<a href="javascript:;" onclick="addElement();">Thêm file đính kèm</a>
							</div>
                            <br />
							<?php
								for($i=2; $i<=$soanh;$i++){
								$hinhanh = $arr_hinhanh[$i-1];
							?>
								<div id="my<?php echo $i;?>Div" style="float:left; width:100%; margin-top:10px;">
									<input type="hidden" id="userfile<?php echo $i;?>" name="sanpham_hinhanh<?php echo $i;?>"  value=""/>
                                  
								</div>
							<?php
								}
							?>
						   </td>
                </tr>
           
             
             <tr class="light" valign="top">
                  <td><input name="pid" id="pid" value="492083" type="hidden">
               <br>
            
               <label>
                  <input class="buttonnew" name="submit" id="submit" value="Lưu lại" type="submit">
               </label>
               	  </td>
             </tr>

            </table>
           </td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
         
      </form>